import {
    Component,
    Injector,
    ViewEncapsulation,
    ViewChild,
    OnInit,
    AfterViewInit,
} from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import {
    SideTaskServiceProxy,
} from '@shared/service-proxies/service-proxies';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppConsts } from '@shared/AppConsts';
import { Table } from 'primeng/table';
import { Paginator, LazyLoadEvent } from 'primeng/primeng';

@Component({
    templateUrl: './dzd-sidetask.component.html',
    styleUrls: ['./dzd-sidetask.component.less'],
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()],
})
export class DzdSidetaskComponent extends AppComponentBase implements AfterViewInit {
    

    @ViewChild('dataTable') dataTable: Table;
    @ViewChild('paginator') paginator: Paginator;

    filterText = '';
    isReceived = true;
    isCompleted = false;
    constructor(
        injector: Injector,
        private _sideTaskServiceProxy: SideTaskServiceProxy,
    ) {
        super(injector);
    }

    ngAfterViewInit(): void {
        this.getSideTasks();
    }
    getSideTasks(event?: LazyLoadEvent) {
        this.primengTableHelper.showLoadingIndicator();
        this._sideTaskServiceProxy
            .getSideTasksByDeptment(
                this.filterText,
                undefined,
                undefined,
                undefined,
                undefined,
                this.primengTableHelper.getSkipCount(this.paginator, event),
                this.primengTableHelper.getMaxResultCount(this.paginator, event)
            )
            .subscribe((result) => {
                this.primengTableHelper.totalRecordsCount = result.totalCount;
                this.primengTableHelper.records = result.items;
                this.primengTableHelper.hideLoadingIndicator();
            });
    }
}
